<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/goods-campus.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" id="head">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">{{title}}</h1>
		</header>
		<div class="mui-content" id="goods_list">
			<li v-if="list.length ==0" class="mui-table-view-cell" style="list-style: none;text-align: center;">该校区暂无数据</li>
			<div class="goods" v-for="goods in list" @click="open_detail(goods.id)">
				<img class="goods_img" :src="goodsImgPath+goods.pictureArray[0]" />
				<div class="des">{{goods.des | intercept}}</div>
				<span class="price">&yen;{{goods.price | currency}}</span>
				<span class="time" v-if="goods.pastHour>=12">{{goods.createTimeText}}</span>
				<span class="time" v-if="goods.pastMinutes==0">刚刚</span>
				<span class="time" v-if="goods.pastMinutes<60 &&goods.pastMinutes>0">{{goods.pastMinutes}}分钟之前</span>
				
			</div>

		</div>
		<script src="../js/mui.min.js"></script>
		<script type="text/javascript" src="../js/vue.min.js"></script>
		<script type="text/javascript" src="../js/const.js"></script>
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../js/goods_service.js"></script>
		<script type="text/javascript">
			
			Vue.filter("intercept",function(value){
				return value.substring(0,10);
			})
			
			var goods_list = new Vue({
				el: '#goods_list',
				data: {
					list: [],
					goodsImgPath: GOODS_IMG_PATH + '/',
					userFacePath: USER_FACE_PATH + '/'
				},
				methods: {
					//打开详情页面
					open_detail: function(id) {
						//触发详情页面的自定义事件
						mui.fire(detailPage, 'goodsId', {
							id: id
						});
						detailPage.show('slide-in-right');
					}
				}
			});

			var header = new Vue({
				el: '#head',
				data: {
					title: '',
				}
			})
			mui.init();

			window.addEventListener("campusList", function(event) {
				campus = event.detail.campus; //获取首页传过来的校区名称
				header.title = campus;
				var res = goodsService.get_campus_list(campus);
				goods_list.list = res.data;

			});
			
			mui.plusReady(function() {
					//给detailPage赋值,根据ID获取详情页面
					detailPage = plus.webview.getWebviewById('goods-detail');
					if(!detailPage) {
						detailPage = mui.preload({
							id: 'goods-detail',
							url: 'html/goods_detail.html'
						});
					}
					
				});
		</script>
	</body>

</html>